package com.caigou.modules.personal.ui.info

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.caigou.comm.base.bean.AppBackgroundInfo
import com.caigou.comm.base.constants.RouterPath
import com.caigou.comm.base.container.BaseFragment
import com.caigou.comm.base.ext.levelAliasImage
import com.caigou.modules.personal.databinding.FragmentLevelBinding
import dagger.hilt.android.AndroidEntryPoint

/**
 * @author #Suyghur.
 * Created on 2021/10/11
 */
@AndroidEntryPoint
class LevelFragment : BaseFragment() {

    private var _binding: FragmentLevelBinding? = null
    private val binding get() = _binding!!

    override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
        _binding = FragmentLevelBinding.inflate(inflater, container, false)
        return _binding?.root
    }

    override fun onBack() {

    }

    override fun initView() {
        binding.levelIvDesc.setImageResource(levelAliasImage(AppBackgroundInfo.instance.userBean!!.level))
        binding.levelTvLvValue.text = "当前成长值：${AppBackgroundInfo.instance.userBean!!.levelGrowthValue}"
        binding.levelTvDetail.setOnClickListener {
            (requireActivity() as PersonalInfoActivity).switchFragment(RouterPath.Personal.TAG_GROWTH_VALUE)
        }

        binding.levelTvBack.setOnClickListener {
            (requireActivity() as PersonalInfoActivity).onBackPressed()
        }
    }

    override fun lazyLoad() {
    }

    override fun onDestroyView() {
        super.onDestroyView()
        _binding = null
    }
}